﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using System.Data.SqlClient;
using Manage_Garage_Car.DataAccessLayer;

namespace Manage_Garage_Car.BusinessLogicLayer
{
    class ReceiveCarBusiness
    {
        #region Fields

        private ConnectData m_connectData = new ConnectData();

        private SqlParameter[] m_sqlParam;

        #endregion

        #region Properties

        public DataTable GetDataReceiveCar()
        {
            return m_connectData.GetDataTable("LOADPHIEUTIEPNHANXE", 0);
        }

        public bool SetDataReceiveCar(string _numberPlate, string _dateReceiveCar, string _timeReceiveCar)
        {
            m_sqlParam[0] = new SqlParameter("@BienSo", SqlDbType.VarChar, 20);
            m_sqlParam[0].Value = _numberPlate;
            m_sqlParam[1] = new SqlParameter("@NgayTiepNhan", SqlDbType.Date);
            m_sqlParam[1].Value = _dateReceiveCar;
            m_sqlParam[2] = new SqlParameter("@GioTiepNhan", SqlDbType.Time, 0);
            m_sqlParam[2].Value = _timeReceiveCar;

            return m_connectData.SetDataTable("ADDPHIEUTIEPNHANXE", 3, m_sqlParam);
        }

        public void DeleteDataReceiveCar(string _numberPlate, string _dateReceiveCar, string _timeReceiveCar)
        {
            m_sqlParam[0] = new SqlParameter("@BienSo", SqlDbType.VarChar, 20);
            m_sqlParam[0].Value = _numberPlate;
            m_sqlParam[1] = new SqlParameter("@NgayTiepNhan", SqlDbType.Date);
            m_sqlParam[1].Value = _dateReceiveCar;
            m_sqlParam[2] = new SqlParameter("@GioTiepNhan", SqlDbType.Time, 0);
            m_sqlParam[2].Value = _timeReceiveCar;

            m_connectData.SetDataTable("DELETEPHIEUTIEPNHANXE", 3, m_sqlParam);
        }

        #endregion

        #region Initialization

        public ReceiveCarBusiness()
        {
            m_connectData = new ConnectData();
            m_sqlParam = new SqlParameter[3];
        }

        #endregion

    }
}
